﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FrameWorkWeb;
using System.Data;
using System.Data.SqlClient;

namespace FrameWork.web.Middle.OperateCS
{
    public class ColConfigItemCS
    {

        public int ColConfigItem_Create(enColConfigItem _enColConfigItem)
        {
            SqlParameter[] sp = new SqlParameter[5]{
				new SqlParameter("@ConfigID",SqlDbType.Int),
				new SqlParameter("@ColDataName",SqlDbType.VarChar,50),
				new SqlParameter("@ColWebName",SqlDbType.VarChar,50),
				new SqlParameter("@ColWidth",SqlDbType.Int),
				new SqlParameter("@ColWidthType",SqlDbType.Int),
			
			};
            //
            if (_enColConfigItem.ConfigID != int.MinValue)
            {
                sp[0].Value = _enColConfigItem.ConfigID;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            //
            if (_enColConfigItem.ColDataName != "")
            {
                sp[1].Value = _enColConfigItem.ColDataName;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (_enColConfigItem.ColWebName != "")
            {
                sp[2].Value = _enColConfigItem.ColWebName;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (_enColConfigItem.ColWidth != int.MinValue)
            {
                sp[3].Value = _enColConfigItem.ColWidth;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (_enColConfigItem.ColWidthType != int.MinValue)
            {
                sp[4].Value = _enColConfigItem.ColWidthType;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            try
            {
                int i = SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.wColConfigItem_Create", sp);
                return i;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public int ColConfigItem_Delete(enColConfigItem _enColConfigItem)
        {
            SqlParameter[] sp = new SqlParameter[1]{
				new SqlParameter("@ID",SqlDbType.Int),
			
			};
            //
            if (_enColConfigItem.ID != int.MinValue)
            {
                sp[0].Value = _enColConfigItem.ID;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            try
            {
                int i = SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.wColConfigItem_DeleteByID", sp);
                return i;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public int ColConfigItem_Delete(int ConfigID)
        {
            SqlParameter[] sp = new SqlParameter[1]{
				new SqlParameter("@ID",SqlDbType.Int),
			
			};
            //
            if (ConfigID!= int.MinValue)
            {
                sp[0].Value = ConfigID;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            try
            {
                int i = SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.wColConfigItem_DeleteByConfigID", sp);
                return i;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public int ColConfigItem_Update(enColConfigItem _enColConfigItem)
        {
            SqlParameter[] sp = new SqlParameter[6]{
				new SqlParameter("@ID",SqlDbType.Int),
				new SqlParameter("@ConfigID",SqlDbType.Int),
				new SqlParameter("@ColDataName",SqlDbType.VarChar,50),
				new SqlParameter("@ColWebName",SqlDbType.VarChar,50),
				new SqlParameter("@ColWidth",SqlDbType.Int),
				new SqlParameter("@ColWidthType",SqlDbType.Int),
			
			};
            //
            if (_enColConfigItem.ID != int.MinValue)
            {
                sp[0].Value = _enColConfigItem.ID;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            //
            if (_enColConfigItem.ConfigID != int.MinValue)
            {
                sp[1].Value = _enColConfigItem.ConfigID;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (_enColConfigItem.ColDataName != "")
            {
                sp[2].Value = _enColConfigItem.ColDataName;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (_enColConfigItem.ColWebName != "")
            {
                sp[3].Value = _enColConfigItem.ColWebName;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (_enColConfigItem.ColWidth != int.MinValue)
            {
                sp[4].Value = _enColConfigItem.ColWidth;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            //
            if (_enColConfigItem.ColWidthType != int.MinValue)
            {
                sp[5].Value = _enColConfigItem.ColWidthType;
            }
            else
            {
                sp[5].Value = DBNull.Value;
            }

            sp[5].Direction = ParameterDirection.Input;


            try
            {
                int i = SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.wColConfigItem_Update", sp);
                return i;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }



    }
}
